package com.ruoyi.blogs.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.blogs.domain.vo.BsCommentVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.blogs.mapper.BsCommentMapper;
import com.ruoyi.blogs.domain.BsComment;
import com.ruoyi.blogs.service.IBsCommentService;

/**
 * 评论Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-30
 */
@Service
public class BsCommentServiceImpl implements IBsCommentService
{
    @Autowired
    private BsCommentMapper bsCommentMapper;

    /**
     * 查询评论
     *
     * @param id 评论主键
     * @return 评论
     */
    @Override
    public BsComment selectBsCommentById(Long id)
    {
        return bsCommentMapper.selectBsCommentById(id);
    }

    /**
     * 查询评论列表
     *
     * @param bsComment 评论
     * @return 评论
     */
    @Override
    public List<BsComment> selectBsCommentList(BsComment bsComment)
    {
        return bsCommentMapper.selectBsCommentList(bsComment);
    }

    /**
     * 新增评论
     *
     * @param bsComment 评论
     * @return 结果
     */
    @Override
    public int insertBsComment(BsComment bsComment)
    {
        bsComment.setCreateTime(DateUtils.getNowDate());
        bsComment.setUserId(SecurityUtils.getUserId());
        bsComment.setUserName(SecurityUtils.getUsername());
        bsComment.setLikeNum(0L);
        bsComment.setBelittleNum(0L);
        return bsCommentMapper.insertBsComment(bsComment);
    }

    /**
     * 修改评论
     *
     * @param bsComment 评论
     * @return 结果
     */
    @Override
    public int updateBsComment(BsComment bsComment)
    {
        return bsCommentMapper.updateBsComment(bsComment);
    }

    /**
     * 批量删除评论
     *
     * @param ids 需要删除的评论主键
     * @return 结果
     */
    @Override
    public int deleteBsCommentByIds(Long[] ids)
    {
        return bsCommentMapper.deleteBsCommentByIds(ids);
    }

    /**
     * 删除评论信息
     *
     * @param id 评论主键
     * @return 结果
     */
    @Override
    public int deleteBsCommentById(Long id)
    {
        return bsCommentMapper.deleteBsCommentById(id);
    }

    @Override
    public List<BsCommentVo> selectBsNoteCommentList(BsComment bsComment) {
        return bsCommentMapper.selectBsNoteCommentList(bsComment);
    }

    @Override
    public int updateBsCommentLike(Map<String, Object> map) {
        return bsCommentMapper.updateBsCommentLike(map);
    }

    @Override
    public int deleteBsCommentByParentId(Long id) {
        return bsCommentMapper.deleteBsCommentByParentId(id);
    }
}